import React from 'react';
import * as asyncLoad from '../util/asyncLoad';
import { workflowPublicFiles } from '../constants/fileConfig';
import Loading from './Loading';

export default class Share extends React.Component{
    constructor(){
        super();
        this.state = {hasLoad: false};
    }
    componentDidMount(){
        const init = () =>{
            const { WfFormShareStore } = window.weaWorkflowPublic;
            const store = new WfFormShareStore();
            this.setState({hasLoad: true,store:store});
        };
        asyncLoad.asyncLoadModule('workflowPublic', workflowPublicFiles, init);
    }
    render(){
        const { hasLoad, store } = this.state;
        if(hasLoad){
            const { WfFormShare } = window.weaWorkflowPublic;
            const { commonParam } = this.props;
            const { requestid,workflowid,nodeid,f_weaver_belongto_userid,f_weaver_belongto_usertype } = commonParam;
            const formParams = {requestid:requestid, workflowid:workflowid, currentnodeid:nodeid, f_weaver_belongto_userid:f_weaver_belongto_userid, f_weaver_belongto_usertype:f_weaver_belongto_usertype};

            return (<WfFormShare ecId={`${this && this.props && this.props.ecId || ''}_WfFormShare@0jyohv`} formParams={formParams} wfShareStore={store} />);
        }else{
            return (<Loading ecId={`${this && this.props && this.props.ecId || ''}_Loading@i1735l`} />);
        }
    }
}